<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 
Inherits="System.Web.Mvc.ViewPage<MvcCms.Web.ViewModels.BackOfficeModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    MvcCms -
    <%=ViewData["PageTitle"]%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="contentpage-outerdiv">
    <h2>
        <%=ViewData["PageTitle"]%></h2>
    <span class="field-validation-error">&nbsp;<%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>
    <%=ViewData["message"].ToString()%></span>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="data-table">
        <tr>
            <th>
                &nbsp;
            </th>
            <th>
                Title
            </th>
            <th>
                Importance
            </th>
            <th>
                Description
            </th>
            <th>
                ShowInNav
            </th>
            <th>
                Path 
            </th>            
        </tr>
        <% foreach (var item in Model._ContentCategories)
           { %>
        <tr>
            <td>
               <%
                   if (item.Title != "Home")
                   { 
                %>
                        <%= Html.ActionLink("Edit", "EditContentCategory", new { id = item.CategoryID })%>
                        |
                        <a href="javascript:void(0)" onclick="DeleteCat(<%=item.CategoryID %>)">Delete</a>
               <%
                   }
                   else
                   {
                %>
                        <%= Html.ActionLink("Edit", "EditHomeCategory", new { id = item.CategoryID })%>
                <%
                   }
               %>&nbsp;
            </td>
            <td>
                <%= Html.Encode(item.Title) %>
            </td>
            <td>
                <%= Html.Encode(item.Importance) %>
            </td>
            <td>
                <%= Html.Encode(item.Description) %>
            </td>
            <td>
                <%if (item.ParentCategory == null)
                  {%>
                <%= Html.Encode(item.ShowInNav)%>
                <%}
                  else
                  { %>                
                    n/a
                <%} %>
            </td>
            <td>
                <%= Html.Encode(item.Path)%>
            </td>            
        </tr>
        <% } %>
    </table>
</div>     
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
<script type="text/javascript">
    function DeleteCat(catid) {
        if(confirm("Are you sure you want to delete this category?")){
            window.location.href = "managecontentcategories/"+catid;
        }
    }
</script>
</asp:Content>
